<?php
namespace App\Api\Movie;

use PhalApi\Api;
use App\Domain\Movie\MovieDetail as MovieDetailDomain;
/**
 * 电影详情
 */
class MovieDetail extends Api
{
    public function getRules()
    {
        return array(
            'getList' => array(
                'id' => array('name' => 'id', 'require' => true)
            ),
            'getMovieDetailInfo' => array(
                'source_id' => array('name' => 'source_id', 'require' => true)
            ),
            'update' => array(
                'id' => array('name' => 'id', 'require' => false),
                'title'=>array('name'=> 'title','require'=>true)
            ),
            'delete'=> array(
                'id'=> array('name'=>'id','require'=>true)
            )
        );
    }
    /**
     * 获取电影详情列表
     * @desc 用于后端获取电影详情
     */
    public function getList() {
        $domain = new MovieDetailDomain();
        $res = $domain->getList($this->id);
        return $res;
    }
    /**
     * 根据source_id获取电影详情
     * @desc 用于根据source_id获取电影详情
     */
    public function getMovieDetailInfo() {
        $domain = new MovieDetailDomain();
        $res = $domain->getMovieDetailInfo($this->source_id);
        return $res;
    }
    /**
     * 更新或添加电影详情
     * @desc 有id则是更新无id则是添加
     */
    public function update() {
        $domain = new MovieDetailDomain();
        $data=array(
            'title'=>$this->title,
            'update_time'=>date('Y-m-d H:i:s',time())
        );
        $res = $domain->update($this->id,$data);
        return $res;
    }
    /**
     * 删除电影详情
     * @desc 删除电影详情
     */
    public function delete() {
        $domain = new MovieDetailDomain();
        $res = $domain->delete($this->id);
        return array($res);
    }

}
